package com.cxy.ch1.safeend;

/**
 * 
 * @ClassName: HasInterrputException
 * @Description: TODO(�����������׳�InterruptedException�쳣�������Ҫ�����жϣ���Ҫ�ֶ����ж�һ��)
 * @author ����Ѽ
 * @date 2020��4��12��
 *
 */
public class HasInterrputException {

	private static class UseThread extends Thread {

		public UseThread(String name) {
			super(name);
		}

		@Override
		public void run() {
			while (!isInterrupted()) {
				try {
					Thread.sleep(100);
				} catch (InterruptedException e) {
					System.out.println(Thread.currentThread().getName() + " in InterruptedException interrupt ��ʶ���� "
							+ isInterrupted());
					// �ͷŲ�������һ��Ϊ�ֶ��ж�
					interrupt();
					e.printStackTrace();
				}
				System.out.println(Thread.currentThread().getName() + " ���Ǽ̳� Thread��.");
			}
			System.out.println(Thread.currentThread().getName() + " interrupt ��ʶ����" + isInterrupted());
		}
	}

	public static void main(String[] args) throws InterruptedException {
		Thread endThread = new UseThread("HasInterrputEx");
		endThread.start();
		Thread.sleep(500);
		endThread.interrupt();

	}

}
